Change in openvpn[master]: iservice: check return value of MultiByteToWideChar
A message that is not in the archive (sent off-list or not yet received): gerrit.1761496209000.I92804da010bab36cd0326759c04f955f2bda74de@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1306?usp=email
to review the following change.
Change subject: iservice: check return value of MultiByteToWideChar
......................................................................
iservice: check return value of MultiByteToWideChar
If the first call to MultiByteToWideChar returns 0, something must have failed, because it returns the required buffer size including the terminating zero. When it does return 0, just return NULL and indicate that the call to utf8to16(_size) failed.
Found by ZeroPath.
---
M src/openvpnserv/common.c
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/06/1306/1
src/openvpnserv/common.c +4 -0
@@ -276,6 +276,10 @@ utf8to16_size(const char *utf8, int size) { int n = MultiByteToWideChar(CP_UTF8, 0, utf8, size, NULL, 0); +if (n ==0 ) + { +return NULL ; + }wchar_t *utf16 =malloc (n *sizeof (wchar_t));if (!utf16) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1306?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I92804da010bab36cd0326759c04f955f2bda74de
Gerrit-Change-Number: 1306
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Attention is currently required from: d12fk, flichtenheld, plaisthos.
cron2 has posted comments on this change by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1306?usp=email )
Change subject: iservice: check return value of MultiByteToWideChar
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1306?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I92804da010bab36cd0326759c04f955f2bda74de
Gerrit-Change-Number: 1306
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Thu, 30 Oct 2025 19:47:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH 1/1 iservice: check return value of MultiByteToWideChar
In reply to a message not in the archiveFrom: Heiko Hund <[email protected]...>
If the first call to MultiByteToWideChar returns 0, something must have failed, because it returns the required buffer size including the terminating zero. When it does return 0, just return NULL and indicate that the call to utf8to16(_size) failed.
Found by ZeroPath.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1306
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1306
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpnserv/common.c +4 -0
@@ -276,6 +276,10 @@ utf8to16_size(const char *utf8, int size) { int n = MultiByteToWideChar(CP_UTF8, 0, utf8, size, NULL, 0); +if (n ==0 ) + { +return NULL ; + }wchar_t *utf16 =malloc (n *sizeof (wchar_t));if (!utf16) {
[Openvpn-devel] [PATCH applied] Re: iservice: check return value of MultiByteToWideChar
Not sure if MultiByteToWideChar() could ever fail here (UTF8 decoding errors are only reported if MB_ERR_INVALID_CHARS is passed in), but then, checking for an error here will ensure that we can't crash further down. So, good practice.
I have verified that all callers of utf8to16_size() and utf8to16() can handle NULL returns fine, so this is safe.
Your patch has been applied to the master and release/2.6 branch (bugfix, with some shoehorning).
commit fdd4072541ba52e297c19672d3b1e7021d14bc91 (master) commit 5b5fdb05d969abc0be7a701c752821299cb98d5e (release/2.6)
Author: Heiko Hund Date: Thu Oct 30 20:47:31 2025 +0100
iservice: check return value of MultiByteToWideChar
Signed-off-by: Heiko Hund <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1306
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34071.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#2) to the change originally created by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1306?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: iservice: check return value of MultiByteToWideChar
......................................................................
iservice: check return value of MultiByteToWideChar
If the first call to MultiByteToWideChar returns 0, something must have failed, because it returns the required buffer size including the terminating zero. When it does return 0, just return NULL and indicate that the call to utf8to16(_size) failed.
Found by ZeroPath.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1306
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34071.html
---
M src/openvpnserv/common.c
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/06/1306/2
src/openvpnserv/common.c +4 -0
@@ -276,6 +276,10 @@ utf8to16_size(const char *utf8, int size) { int n = MultiByteToWideChar(CP_UTF8, 0, utf8, size, NULL, 0); +if (n ==0 ) + { +return NULL ; + }wchar_t *utf16 =malloc (n *sizeof (wchar_t));if (!utf16) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1306?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I92804da010bab36cd0326759c04f955f2bda74de
Gerrit-Change-Number: 1306
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1306?usp=email )
Change subject: iservice: check return value of MultiByteToWideChar
......................................................................
iservice: check return value of MultiByteToWideChar
If the first call to MultiByteToWideChar returns 0, something must have failed, because it returns the required buffer size including the terminating zero. When it does return 0, just return NULL and indicate that the call to utf8to16(_size) failed.
Found by ZeroPath.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1306
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34071.html
---
M src/openvpnserv/common.c
1 file changed, 4 insertions(+), 0 deletions(-)
src/openvpnserv/common.c +4 -0
@@ -276,6 +276,10 @@ utf8to16_size(const char *utf8, int size) { int n = MultiByteToWideChar(CP_UTF8, 0, utf8, size, NULL, 0); +if (n ==0 ) + { +return NULL ; + }wchar_t *utf16 =malloc (n *sizeof (wchar_t));if (!utf16) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1306?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I92804da010bab36cd0326759c04f955f2bda74de
Gerrit-Change-Number: 1306
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>